/*
 * @Author: your name
 * @Date: 2021-06-19 11:29:08
 * @LastEditTime: 2022-03-19 14:27:35
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /shujucaiji/lib/db/index.js
 */
const mongoose = require('mongoose');

const CONFIG = require('../../config');

// 数据库验证信息
const options = {
  user:CONFIG.DB_USER,
  pass:CONFIG.DB_SECRET,
  useNewUrlParser: true,
  useCreateIndex:true,
  useUnifiedTopology: true,
};

//连接数据库
mongoose.connect(`mongodb://127.0.0.1/${CONFIG.DB_NAME}`,options);

//导出对象
const DB =()=>{};

//创建Model
DB.Project = mongoose.model('Project', require('./_Project')); // 项目信息
DB.Record = mongoose.model('Record',require('./_Record')); // 车辆工作信息记录
DB.Vehicle = mongoose.model('Vehicle',require('./_Vehicle')); // 车辆信息
DB.Warn = mongoose.model('Warn',require('./_Warn')); // 车辆告警信息
DB.Operator = mongoose.model('Operator', require('./_Operator')); // 操作员信息
DB.Summary = mongoose.model('Summary', require('./_Summary')); // 司钻信息记录表
DB.Orientation = mongoose.model('Orientation', require('./_Orientation'));

//导出
module.exports = DB;